#include<stdio.h>
int main()
{
	int a[120], b[120], c[120];
	int i = 0, m = 0;
	int j = 0, n = 0;
	int k = 0, t;

	while (1)
	{
		scanf("%d", &a[i]);
		if (a[i] == -1)
			break;
		i++;
		m++;
	}

	while (1)
	{
		scanf("%d", &b[j]);
		if (b[j] == -1)
			break;
		j++;
		n++;
	}

	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (a[i] == b[j])
			{
				c[k] = a[i];
				k++;
				break;
			}
		}
	}

	for (i = 0; i < k; i++)
	{
		for (j = i+1; j < k; j++)
		{
			if (c[j]<c[i])
			{
				t = c[j];
				c[j] = c[i];
				c[i] = t;
			}
		}
	}

	for (i = 0; i < k; i++)
	{
		printf("%d ", c[i]);
	}

	return 0;
}


